package com.seari.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.seari.bean.EmergencyEquipment;
import com.seari.bean.EmergencyTeam;
import com.seari.bean.ServiceCompany;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.seari.bean.FaultNum;
import com.seari.pojo.MessageBean;
import com.seari.service.EmergencyResourcesService;

/**
 * 应急资源
 *
 * @author liuqi
 */
@RestController
public class EmergencyResourcesController {

    @Autowired
    public EmergencyResourcesService emergencyResourcesService;


    /**
     * 应急资源(废弃)
     * 获取应急资源 应急队伍  应急物资 机动车等
     *
     * @return
     */
    @RequestMapping(value = "/fault/getEmergencyResources")
    public MessageBean getEmergencyResources() {

        MessageBean messageBean = new MessageBean();
        try {
            Map<String, Object> dataMap = new HashMap<String, Object>();

            FaultNum faultNum = emergencyResourcesService.getEmergencyResources();
            dataMap.put("faultNum", faultNum);

            messageBean.setType("success");
            messageBean.setCode("1000");
            messageBean.setMessage("应急资源获取成功 ");
            messageBean.setData(dataMap);
        } catch (Exception e) {
            e.printStackTrace();
            messageBean.setType("fail");
            messageBean.setCode("3000");
            messageBean.setMessage("应急资源获取失败");
        }

        return messageBean;
    }

    /**
     * 获取应急应急队伍
     * 抢修队
     * @return
     */
    @RequestMapping(value = "/fault/getEmergencyTeams")
    public MessageBean getEmergencyTeams() {

        MessageBean messageBean = new MessageBean();
        try {
            Map<String, Object> dataMap = new HashMap<String, Object>();

//          List<EmergencyEquipment> emergencyEquipments = emergencyResourcesService.getEmergencyEquipment();
            List<EmergencyTeam> emergencyTeams = emergencyResourcesService.getEmergencyTeam();

 //         dataMap.put("emergencyEquipments", emergencyEquipments);
            dataMap.put("emergencyTeams", emergencyTeams);

            messageBean.setType("success");
            messageBean.setCode("1000");
            messageBean.setMessage("应急队伍获取成功 ");
            messageBean.setData(dataMap);
        } catch (Exception e) {
            e.printStackTrace();
            messageBean.setType("fail");
            messageBean.setCode("3000");
            messageBean.setMessage("应急队伍获取失败");
        }

        return messageBean;
    }


    /**
     * 接修单位及其ID编码
     */
    @RequestMapping(value = "/fault/gzZyList")
    public MessageBean gzZyList() {
        MessageBean messageBean = new MessageBean();

        try {

            Map<String, Object> dataMap = new HashMap<String, Object>();
            List<ServiceCompany> gzZyLists = emergencyResourcesService.getGzZyList();

            dataMap.put("gzZyList", gzZyLists);
            messageBean.setType("success");
            messageBean.setCode("1000");
            messageBean.setMessage("应急接修单位获取成功 ");
            messageBean.setData(dataMap);
        } catch (Exception e) {
            e.printStackTrace();
            messageBean.setType("fail");
            messageBean.setCode("3000");
            messageBean.setMessage("应急接修单位获取失败");
        }

        return messageBean;

    }

}
